package com.kinptm.masterclock.adapter.item;

import android.view.LayoutInflater;
import android.view.View;

import com.kinptm.masterclock.R;
import com.kinptm.masterclock.adapter.ViewBuilder;
import com.kinptm.masterclock.bean.StopWatchRecord;
import com.kinptm.masterclock.utils.TimeUtil;
import com.kinptm.masterclock.utils.ViewUtil;

/**
 * Created by pc on 13-11-8.
 */
public class StopWatchItemBuilder extends ViewBuilder<StopWatchRecord> {

    @Override
    public View createView(LayoutInflater inflater, int position, StopWatchRecord data) {
        View view = inflater.inflate(R.layout.list_item_stopwatch_record, null);
        updateView(view, position, data);
        return view;
    }

    @Override
    public void updateView(View view, int position, StopWatchRecord data) {
        super.updateView(view, position, data);
        ViewUtil.findTextViewAndSetText(view, R.id.stopwatch_item_record_id_tv, "记录 " + (position + 1));
        ViewUtil.findTextViewAndSetText(view, R.id.stopwatch_item_record_time_tv, TimeUtil.transform2TimeAndFormat(data.getSpendTime()));
        ViewUtil.findTextViewAndSetText(view, R.id.stopwatch_item_record_all_time_tv, TimeUtil.transform2TimeAndFormat(data.getTotalTime()));
    }
}
